local baogan = fk.CreateSkill {
  name = "rmt__baogan",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["rmt__baogan"] = "爆肝",
  [":rmt__baogan"] = "锁定技，你有100%的概率能在出牌阶段结束后执行一个额外出牌阶段。若你在一个额外出牌阶段未能使用牌，则结束回合，"..
  "且概率永久降低10%。",
}

baogan:addEffect(fk.EventPhaseEnd, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(baogan.name) and player.phase == Player.Play
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:broadcastSkillInvoke(baogan.name)
    if player:getMark(baogan.name) < 11 and
      player:usedSkillTimes(baogan.name, Player.HistoryTurn) > 1 and
      #room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
        return e.data.from == player
      end, Player.HistoryPhase) == 0 then
        room:notifySkillInvoked(player, baogan.name, "negative")
      room:addPlayerMark(player, baogan.name, 1)
      room:endTurn()
    elseif math.random() < 1 - 0.1 * player:getMark(baogan.name) then
      room:notifySkillInvoked(player, baogan.name, "support")
      player:gainAnExtraPhase(Player.Play, baogan.name)
    end
  end,
})

return baogan
